Skip to content

refactor: extract partial eval loop unrolling - #186

Merged
lbliii merged 1 commit into
mainfrom
codex/split-partial-eval-loops
Jul 7, 2026
Merged

refactor: extract partial eval loop unrolling#186
lbliii merged 1 commit into
mainfrom
codex/split-partial-eval-loops

Conversation

@lbliii

@lbliii lbliii commented Jul 7, 2026

Copy link
Copy Markdown
Owner

Summary

  • extract static for-loop transformation and unrolling into a phase-owned internal mixin
  • move compile-time loop properties and iteration-context construction with that phase
  • keep PartialEvaluator slot-only and concrete while sharing the existing 200-item bound with list-comprehension evaluation

Progresses #143.

Steward Notes

  • consulted: compiler and testing stewards
  • risk: MRO or state-layout drift in a compiler hot path, plus semantic drift in scoped loop contexts
  • evidence: the mixin has no slots/state, PartialEvaluator remains concrete with no instance __dict__, focused and stability suites pass, and isolated free-threaded benchmarks show no regression
  • unresolved tradeoffs: call/def inlining and the remaining control-flow/expression phases stay in Split partial evaluation into smaller phase-owned modules #143

Verification

  • 319 passed in the focused partial-evaluation suite
  • make verify-stability (4,459 passed, 5 skipped)
  • ruff check, ruff format --check, and ty check clean
  • Python 3.14.2 free-threaded isolated before/after benchmarks: compile-pipeline medians within noise or faster; partial-evaluation medians within noise or faster

Collateral

  • no docs/changelog/API collateral: internal behavior-preserving phase extraction
  • no benchmark baseline update: no reproducible regression

@lbliii
lbliii marked this pull request as ready for review July 7, 2026 16:51
Copilot AI review requested due to automatic review settings July 7, 2026 16:51
@lbliii
lbliii merged commit 9a166e8 into main Jul 7, 2026
10 checks passed
@lbliii
lbliii deleted the codex/split-partial-eval-loops branch July 7, 2026 16:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR refactors partial-evaluation static for-loop unrolling by extracting the transformation logic into a dedicated, phase-owned internal mixin module, while keeping PartialEvaluator concrete and slot-based. This aligns with issue #143’s goal of splitting partial_eval.py into smaller, behavior-scoped units without changing the public entrypoint.

Changes:

  • Extracted static for-loop transformation + unrolling into LoopUnrollingMixin (partial_eval_loops.py) and made PartialEvaluator inherit it.
  • Moved compile-time loop-context properties (loop.*) into the new module (LoopProperties).
  • Centralized the 200-iteration unroll bound so both loop unrolling and list-comprehension evaluation share the same limit (MAX_UNROLL).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/kida/compiler/partial_eval.py Switches PartialEvaluator to inherit loop-unrolling behavior from the extracted mixin and shares the unroll bound with list comprehensions.
src/kida/compiler/partial_eval_loops.py Introduces an internal mixin implementing static for-loop unrolling and compile-time loop.* properties.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants